﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Example13.aspx.cs" Inherits="Chapter34.Example13" %>

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>代码清单 34-13 替换默认的媒体控件</title>
    <meta name="author" content="Adam Freeman" />
    <meta name="description" content="A simple example" />
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
    <video id="media" preload="auto" width="360" height="240">
        <source src="Example12.timessquare.webm" />
        <source src="Example12.timessquare.ogv" />
        <source src="Example12.timessquare.mp4" />
        Video cannot be displayed
    </video>
    <div>
        <button>Play</button>
        <button>Pause</button>
    </div>
    <script>
        var mediaElem = document.getElementById('media');
        var buttons = document.getElementsByName('button');
        for (var i = 0; i < buttons.length; i++) {
            buttons[i].onclick = handleButtonPress;
        }

        function handleButtonPress(e) {
            switch (e.target.innerHTML) {
                case 'Play':
                    mediaElem.play();
                    break;
                case 'Pause':
                    mediaElem.pause();
                    break;
            }
        }
    </script>
</body>
</html>
